library("haven")
# install.packages("plyr")
library("plyr")
setwd("C:\\Users\\Public\\Documents\\Results\\Segreg")

is90y_32005 <- read_sas("is90y_32005.sas7bdat")
is90y_32005$year <- 2005
is90y_32008 <- read_sas("is90y_32008.sas7bdat")
is90y_32008$year <- 2008
is90y_32011 <- read_sas("is90y_32011.sas7bdat")
is90y_32011$year <- 2011
is90y_32014 <- read_sas("is90y_32014.sas7bdat")
is90y_32014$year <- 2014
is90y_32017 <- read_sas("is90y_32017.sas7bdat")
is90y_32017$year <- 2017

is90y_3 <- rbind(is90y_32005,is90y_32008,is90y_32011,is90y_32014,is90y_32017)

is90y_3$type <- "is90y_3"


is90y2005 <- read_sas("is90y2005.sas7bdat")
is90y2005$year <- 2005
is90y2008 <- read_sas("is90y2008.sas7bdat")
is90y2008$year <- 2008
is90y2011 <- read_sas("is90y2011.sas7bdat")
is90y2011$year <- 2011
is90y2014 <- read_sas("is90y2014.sas7bdat")
is90y2014$year <- 2014
is90y2017 <- read_sas("is90y2017.sas7bdat")
is90y2017$year <- 2017

is90y <- rbind(is90y2005,is90y2008,is90y2011,is90y2014,is90y2017)

is90y$type <- "is90y"


is90ybis2005 <- read_sas("is90ybis2005.sas7bdat")
is90ybis2005$year <- 2005
is90ybis2008 <- read_sas("is90ybis2008.sas7bdat")
is90ybis2008$year <- 2008
is90ybis2011 <- read_sas("is90ybis2011.sas7bdat")
is90ybis2011$year <- 2011
is90ybis2014 <- read_sas("is90ybis2014.sas7bdat")
is90ybis2014$year <- 2014
is90ybis2017 <- read_sas("is90ybis2017.sas7bdat")
is90ybis2017$year <- 2017

is90ybis <- rbind(is90ybis2005,is90ybis2008,is90ybis2011,is90ybis2014,is90ybis2017)

is90ybis$type <- "is90ybis"

is90 <- rbind.fill(is90y_3,is90y,is90ybis)


is99y_32005 <- read_sas("is99y_32005.sas7bdat")
is99y_32005$year <- 2005
is99y_32008 <- read_sas("is99y_32008.sas7bdat")
is99y_32008$year <- 2008
is99y_32011 <- read_sas("is99y_32011.sas7bdat")
is99y_32011$year <- 2011
is99y_32014 <- read_sas("is99y_32014.sas7bdat")
is99y_32014$year <- 2014
is99y_32017 <- read_sas("is99y_32017.sas7bdat")
is99y_32017$year <- 2017

is99y_3 <- rbind(is99y_32005,is99y_32008,is99y_32011,is99y_32014,is99y_32017)

is99y_3$type <- "is99y_3"


is99y2005 <- read_sas("is99y2005.sas7bdat")
is99y2005$year <- 2005
is99y2008 <- read_sas("is99y2008.sas7bdat")
is99y2008$year <- 2008
is99y2011 <- read_sas("is99y2011.sas7bdat")
is99y2011$year <- 2011
is99y2014 <- read_sas("is99y2014.sas7bdat")
is99y2014$year <- 2014
is99y2017 <- read_sas("is99y2017.sas7bdat")
is99y2017$year <- 2017

is99y <- rbind(is99y2005,is99y2008,is99y2011,is99y2014,is99y2017)

is99y$type <- "is99y"


is99ybis2005 <- read_sas("is99ybis2005.sas7bdat")
is99ybis2005$year <- 2005
is99ybis2008 <- read_sas("is99ybis2008.sas7bdat")
is99ybis2008$year <- 2008
is99ybis2011 <- read_sas("is99ybis2011.sas7bdat")
is99ybis2011$year <- 2011
is99ybis2014 <- read_sas("is99ybis2014.sas7bdat")
is99ybis2014$year <- 2014
is99ybis2017 <- read_sas("is99ybis2017.sas7bdat")
is99ybis2017$year <- 2017

is99ybis <- rbind(is99ybis2005,is99ybis2008,is99ybis2011,is99ybis2014,is99ybis2017)

is99ybis$type <- "is99ybis"

is99 <- rbind.fill(is99y_3,is99y,is99ybis)

is90$iso <- 90
is99$iso <- 99

is <- rbind.fill(is90,is99)

write.csv(is,"isolation.csv")
